package org.file5.domain;

import java.util.List;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableProperty;

import com.google.appengine.api.datastore.Text;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cached;
import com.googlecode.objectify.annotation.NotSaved;

@Searchable(alias = "Category")
@Cached
public class Category extends BaseEntity {

	/** 
	 *   
	 */
	private static final long serialVersionUID = -664941600066257452L;


	@SearchableProperty(name = "name")
	private String name;


	@SearchableProperty(converter = "textConverter", name = "shortDesc")
	private Text shortDesc;

	private Key<Category> primaryParentKey;

	@NotSaved
	private List<Category> childCategories;
	
	@NotSaved
	private List<Category> primaryCategoryTrail;
	// -------------BaseEntity Fields------------

	public Category() {
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}



	public String getShortDesc() {
		return (shortDesc == null) ? "" : shortDesc.getValue();
	}

	// creating a new Text(null) causes a datanucleus Exception
	public void setShortDesc(String shortDesc) {
		this.shortDesc = new Text((shortDesc == null) ? "" : shortDesc);
	}


	public Key<Category> getPrimaryParentKey() {
		return primaryParentKey;
	}


	public void setPrimaryParentKey(Key<Category> primaryParentKey) {
		this.primaryParentKey = primaryParentKey;
	}


	public List<Category> getChildCategories() {
		return childCategories;
	}


	public void setChildCategories(List<Category> childCategories) {
		this.childCategories = childCategories;
	}


	public List<Category> getPrimaryCategoryTrail() {
		return primaryCategoryTrail;
	}


	public void setPrimaryCategoryTrail(List<Category> primaryCategoryTrail) {
		this.primaryCategoryTrail = primaryCategoryTrail;
	}

//
//
//	public static enum Type{
//		SITE_PRODUCT, //站内产品分类
//		GENERAL_PRODUCT, //通用产品分类
//		AREA,         //地区分类
//		BUSINESS      //业务分类
//	}

}
